package com.juitar.base.enumerator;

/**
 * @author SKopylov
 *
 */
/**
 * Usage
 * <pre>
 * <code>
 * do { get() } while (hasNext());
 * </code>
 * </pre> 
 */

public class FingeringEnumerator {

	IFretEnumerator[] fretEnum;

	public FingeringEnumerator(IFretEnumerator[] fretEnum) {
		this.fretEnum = fretEnum;
	}

	public boolean hasNext() {
		for (int i = 0, ii = fretEnum.length; i < ii; i++) {
			if (fretEnum[i].next() == true) {
				return true;
			} else {
				fretEnum[i].reset();
			}
		}
		return false;
	}

	public int[] get() {
		int fing[] = new int[fretEnum.length];
		for (int i = 0; i < fretEnum.length; i++) {
			fing[i] = fretEnum[i].get();
		}
		return fing;
	}
}
